{extend name="layout/detail" /}

{block name="content"}
<input type="hidden" name="ajax" id="ajax" value="1">
<div class="td-content-wrap p20">
    <div class="td-content-header">
        <h1 class="main-title">编辑分类</h1>
    </div>
    <hr>
    <div class="space-20"></div>
    <form id="form_data" class="layui-form" method="post" action="{:url('save')}">
        <input type="hidden" name="opmode" value="edit">
        <input type="hidden" name="id" id="id" value="{$category.id}">
        <div class="layui-form-item">
            <label class="layui-form-label required">名称：</label>
            <div class="layui-input-block w34">
                <input type="text" name="name" placeholder="请输入名称" class="layui-input" check="required"
                       info="请输入名称" value="{$vo.name}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">上级分类：</label>
            <div class="layui-input-block w34">
                <input type="hidden" id="pid" name="pid" value="{$vo.pid}">
                <input type="text" id="pid_name" name="pid_name" placeholder="请选择上级分类" class="layui-input"
                       value="{$vo.pid_name}"
                       check="required" info="请选择上级分类" readonly="readonly">
                <a class="add-on" onclick="select_pid();"><i class="fa fa-search"></i></a>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">栏目属性：</label>
            <div class="layui-input-block w19">
                <input type="radio" name="column" value="list" {:in_val('list',$vo.column,'checked')}/>列表模板<br>
                <input type="radio" name="column" value="article" {:in_val('article',$vo.column,'checked')}/>文章模板<br>
                <input type="radio" name="column" value="url" {:in_val('url',$vo.column,'checked')}/>跳转
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">列表模板：</label>
            <div class="layui-input-block w34">
                <input type="text" name="list_template" placeholder="请输入列表模板" class="layui-input"
                       value="{$vo.list_template}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">文章模板：</label>
            <div class="layui-input-block w34">
                <input type="text" name="article_template" placeholder="请输入文章模板" class="layui-input"
                       value="{$vo.article_template}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">URL：</label>
            <div class="layui-input-block w34">
                <input type="text" name="url" placeholder="请输入URL" class="layui-input" value="{$vo.url}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">图标：</label>
            <div class="layui-input-inline">
                <input type="text" name="icon" placeholder="请输入图标" class="layui-input" value="{$vo.icon}">
            </div>
            <div class="layui-form-mid">

            </div>
        </div>
     <!--    <div class="layui-form-item">
            <label class="layui-form-label">图片：</label>
            <div class="layui-input-block">
                <div class="image-upload {:notempty($vo.image,'active')}">
                    <div class="input">
                        <input type="hidden" class="image-url" name="image" value="{$vo.image}">
                    </div>
                    <div class="image-upload-btn">
                        上传图片
                    </div>
                    <div class="image">
                        <a class="del"><i class="iconfont td-close" aria-hidden="true"></i></a>
                        <img src="{$vo.image}">
                    </div>
                </div>

            </div>
        </div> -->
        <div class="layui-form-item">
            <label class="layui-form-label">图片：</label>
            <div class="layui-input-block">
                <div class="image-upload">
                    <div class="input">
                        <input type="hidden" class="image-url" name="image" value="{$vo.image}">
                    </div>
                    <div class="image-upload-btn">
                        上传图片
                    </div>
                    <div class="image">

                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序：</label>
            <div class="layui-input-block w8">
                <input type="text" name="sort" class="layui-input">
            </div>
        </div>
        <hr>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
                <a class="layui-btn" lay-submit="" lay-filter="demo2" onclick="save();">保存</a>
                <a class="layui-btn layui-btn-primary" onclick="go_return_url();">取消</a>
            </div>
        </div>
    </form>
</div>
{/block}

{block name="script"}
<script>
    layui.use(['form','uploader'], function () {
        var fn = {
            select_pid: function () {
                popup_open("{:url('select_pid')}", 560, 470);
            },
            save: function () {
                send_form("form_data", "{:url('save')}", function (res) {
                    if (res.code) {
                        layer.msg(res.msg, {
                            time: 1200
                        }, function () {
                            location.href = "{:url('index')}";
                        });
                    } else {
                        layer.msg(res.msg);
                        return false;
                    }
                });
            }
        };
        win_exp(fn);

    });
</script>
{/block}
